﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.ModelInterface;
using QLBH.Model.Controller;
using QLBH.DataModel;

namespace QLBH.FeatureModel
{
    public class PhieuChuyenKhoModel:IPhieuChuyenKhoModel
    {
        private Guid pckid;
        private String pckcode;
        private Guid nvid;
        private String userName;
        private Guid khoxuatid;
        private String khoxuatname;
        private Guid khonhapid;
        private String khonhapName;
        private DateTime ngaychuyen;
        private String ghichu;
        private Guid phieuchiid;
        public Guid PCKID
        {
            get
            {
                return pckid;
            }
            set
            {
                pckid = value;
            }
        }

        public string PCKCODE
        {
            get
            {
                return pckcode;
            }
            set
            {
                pckcode = value;
            }
        }

        public Guid USERID
        {
            get
            {
                return nvid;
            }
            set
            {
                nvid = value;
            }
        }
        public String USERNAME
        {
            get
            {
                return userName;
            }
            set
            {
                userName = value;
            }
        }

        public Guid KHOXUATID
        {
            get
            {
                return khoxuatid;
            }
            set
            {
                khoxuatid = value;
            }
        }

        public string KHOXUATNAME
        {
            get
            {
                return khoxuatname;
            }
            set
            {
                khoxuatname = value;
            }
        }

        public Guid KHONHAPID
        {
            get
            {
                return khonhapid;
            }
            set
            {
                khonhapid = value;
            }
        }

        public string KHONHAPNAME
        {
            get
            {
                return khonhapName;
            }
            set
            {
                khonhapName = value;
            }
        }

        public DateTime NGAYCHUYEN
        {
            get
            {
                return ngaychuyen;
            }
            set
            {
                ngaychuyen = value;
            }
        }

        public string GHICHU
        {
            get
            {
                return ghichu;
            }
            set
            {
                ghichu = value;
            }
        }

        public Guid PHIEUCHIID
        {
            get
            {
                return phieuchiid;
            }
            set
            {
                phieuchiid = value;
            }
        }

        public void InitFromEntity(DataModel.PHIEUCHUYENKHO entity)
        {
            this.pckid = entity.PCKID;
            this.pckcode = entity.PCKCODE;
            this.nvid = entity.NVID;
            khoxuatid = entity.KHOXUATID;
            khonhapid = entity.KHONHAPID;
            ngaychuyen = (DateTime)entity.NGAYCHUYEN;
            ghichu = entity.GHICHU;

            USERNAME = NhanVienController.GetInstance().FindBy(e => e.NVID == nvid).FirstOrDefault().TENNV;

            KHOXUATNAME = KhoController.GetInstance().FindBy(e => e.KHOID == khoxuatid).FirstOrDefault().TENKHO;

            KHONHAPNAME = KhoController.GetInstance().FindBy(e => e.KHOID == khonhapid).FirstOrDefault().TENKHO;
        }

        public DataModel.PHIEUCHUYENKHO ToEntity()
        {
            PHIEUCHUYENKHO entity = new PHIEUCHUYENKHO();
            entity.GHICHU = ghichu;
            entity.KHONHAPID = khonhapid;
            entity.KHOXUATID = khoxuatid;
            entity.NGAYCHUYEN = ngaychuyen;
            entity.NVID = nvid;
            entity.PCKCODE = pckcode;
            entity.PCKID = pckid;

            return entity;
        }
    }
}
